package com.ruoyi.user.config;

import com.alibaba.cloud.nacos.util.InetIPv6Utils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.commons.util.InetUtilsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

    // 定义自己的 InetUtilsProperties Bean，使用不同的名字
    @Bean(name = "customInetUtilsProperties")
    public InetUtilsProperties inetUtilsProperties() {
        return new InetUtilsProperties();
    }

    // 使用 @Qualifier 指定注入的 Bean
    @Bean
    @ConditionalOnMissingBean
    public InetIPv6Utils inetIPv6Utils(@Qualifier("customInetUtilsProperties") InetUtilsProperties properties) {
        return new InetIPv6Utils(properties);
    }
}
